#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
    string formatString(string str, vector<char>& arg)
    {
        int j = 0;
        string ret;

        for (int i = 0; i < str.size(); i++) {
            if (str[i] == '%') {
                if (i + 1 < str.size() && str[i + 1] == 's') {
                    ret += arg[j++];
                    i++;
                }
                else {
                    ret += str[i];
                }
            }
            else {
                ret += str[i];

            }
        }

        while (j < arg.size())
        {
            ret += arg[j++];
        }

        return ret;
    }

};

int main()
{
    Solution s;
    vector<char> v = {'B','D','F'};
    s.formatString("A%sC%sE", v);
    return 0;
}